package com.pedromassango.delyo.ui.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import cn.swu.homework1.Food
import cn.swu.homework1.FoodAdapter
import cn.swu.homework1.food
import com.pedromassango.delyo.R
import kotlinx.android.synthetic.main.restaurantfragment.*

class RestaurantFragment: Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.restaurantfragment,container,false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initdata()
        recycler.layoutManager= LinearLayoutManager(context)
        recycler.adapter= FoodAdapter(food)
    }

    private fun initdata() {
        for(i in 1..10)
        {
            food.add(Food().apply {
                name = "多肉葡萄"
                description = "多多的葡萄，多多的芝士，家人们，就是说一整个nice！"
                picture = R.mipmap.grape
            })
            food.add(Food().apply {
                name = "杨枝甘露"
                description = "清凉解渴！享受果味！沁人心脾！"
                picture = R.mipmap.yangzhi
            })
            food.add(Food().apply {
                name = "雪王大圣代（奥利奥）"
                description = "夏天的必需品！便宜实惠冲啊！"
                picture = R.mipmap.ice
            })
        }
    }
}